home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / Codeworks 0.94b3 / Codeworks® WWW Demo Doc. / Scripting Manual.doc / Scripting Manual.doc.rsrc / TEXT_155.txt < prev    next >
Encoding:
Text File  |  1995-05-01  |  4.8 KB  |  50 lines

  1. Objects
  2. Objects are the fundamental way that all information is stored and manipulated in the system.  An object has information and operations (properties) that describe some entity that a program works with.  For example a receipt might be an object in a retail sales program.  The receipt object would have information such as the date, which items were bought, and the sales price.  The receipt object would also describe operations such as calculating the tax, updating inventory, and voiding the sale.
  3.  
  4.     All information in the language is contained in objects.  This includes ordinary data like numbers and lists, as well as complex data such as a sales receipt.  Programming in this system consists of building objects with information and operations.
  5.  
  6. !!    An object is an entity in the system which can have state, receive messages and interact with other objects.  Objects are created in response to user and program actions such as new and copy.  Objects are destroyed automatically when they are no longer referenced by any other object.
  7.  
  8.  
  9. Properties
  10.     An object can have one or more properties.  A property is a named value or script in the object (like instance variables and methods in other object systems).
  11.  
  12.     The name of a property is any valid symbol according to the following rules:
  13. ‚Ä¢    Any string of alpha-numeric and hyphen characters starting with a letter, case is disregarded
  14.         line-width    speed    the-1st-appointment    xjs5000
  15. ‚Ä¢    Any string of the graphic characters: !#$%&*+-/:<=>?@\^|~
  16.     (except the sequences :=, ?=, ?, !, and ???)
  17.         +    ==    >=    &&
  18.  
  19.  
  20. Inheritance
  21.     Each object can inherit properties from another object.  These two objects form a parent/child relationship.  This can be repeated: the child object can itself be the parent to other objects, and the parent object can be the child of yet some other object (cycles are not allowed).  These parent/child relationships form a tree (also know as a directed, acyclic graph).  At the root of the tree is an object that has no parent.  Typically this object is the object called object[Footnote #1][Footnote #2].
  22.  
  23.     When something in the system attempts to reference a property of a given object, in general, first the object is checked to see if it has the property.  If not then its parent is checked, then the parent‚Äôs parent and so on until either the property is found, or there are no more parents to check.  This process is called ‚Äòlookup‚Äô.  If the property is found in one of the parents, then it is said to be an inherited property.  There are some variations on this process, see property scopes, and self sends below.  
  24.  
  25.     Every object has a property called parent.  The value of the parent property is the parent of the object.  If the object doesn‚Äôt have a parent (for example object doesn‚Äôt) then the value of this property is nil.
  26.  
  27.  
  28. Creating New Objects
  29.     New objects are created in response to user and program actions.  There are two basic ways that an object can be created: coping and newing.  All other ways in which cause an object to be created are simply variants of these two operations.  Copying an object creates a new object that is like the original in all respects, except that it is new and distinct object.  Newing an object creates a new object which is a child of the original.  In this case the new object is generally like the original because it inherits all the properties of it.  However, the new object has its own copies of each ‚Äòinstance‚Äô property.
  30.  
  31.  
  32. Property Scopes
  33.     Each property also has a scope.  The scope determines how the property should be handled during the lookup process and during spawning.  There are three scopes:
  34.  
  35. ¬†     Instance properties are copied for each child during newing.  Thus child objects don‚Äôt need to inherit them as each have their own copy.  (Instance properties are inherited in the rare cases where a child doesn‚Äôt have its own copy.)
  36.  
  37.  ¬†    Class properties are accessible to all operations.  Child objects inherit these properties.  They have no special effect on newing.
  38.  
  39.      ¬†Private properties are accessible only for this object.  Child objects do not inherit these properties.  They have no special effect on newing.
  40.  
  41.  
  42.  
  43. Values
  44.     A property of an object may either name a script or a value.  When it names a value, this value be any other object, such as the number 17, the value true, or a sales receipt.  This value is actually a reference to the other object, and thus two or more properties in any number of objects can all have the same value.
  45.  
  46.  
  47.  
  48. Garbage Collection
  49.     While objects are explicitly created in response to various user and program actions, objects are not explicitly destroyed.  Instead, the system figures out when an object is no longer needed (because no property in no object refers to it anymore), and then destroys it.  This process is called garbage collection and takes place in the background.
  50.